/* Name:	Ben Spencer
   Program: 	basedriver.cpp
*/

#include "Card.h"
#include "stack_array.h"
#include <iostream>
#include <string>
#include <sstream>
using namespace std;


int main() {

	int currIndex = -1; //index of Card
	char goForward = 'n';
	char showAnswer= 'n';
	stack_array<Card>* list1 = new stack_array<Card>;//stack array of cards
	Card* currCard = new Card();//temp to store a card

	//insert cards for testing to array stack
	for (int x=0;x<10;x++){
		string question = "this is test question ";
		string answer = "this is test answer ";
		stringstream q;
		q << question << x;
		stringstream a;
		a << answer << x;
		Card *testCard = new Card(q.str(),a.str());
		list1->push(*testCard);
	}

	//main prompt

	cout << "Next Card? (y/n) " << endl;
	cin >> goForward;

	if (list1->length() - 1 >= 0){
		currIndex=0;
	}

	while (goForward=='y' && currIndex>=0){
		*currCard = list1->getIndex(currIndex);
		cout << "Question " << currIndex << ": " << currCard->showQuestion() << endl;

		cout << "Display Answer? (y/n): ";
		cin >> showAnswer;

		if (showAnswer=='y'){
			cout << "Answer " << currIndex << ": " << currCard->showAnswer() << endl;
		}

		cout << "Next Card? (y/n): " << endl;
		cin >> goForward;
		//increment
		currIndex++;
		//reset to beginning if beyond end of list
		if(currIndex > list1->length() - 1){
			currIndex=0;
		}
	}



}
